﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Common;
using DAL;
using Model;
namespace UI.system.page.product
{
    public partial class productadd : BaseAdmin
    {
        public ProductInfo info = new ProductInfo();
        public string categorys = "";
        public List<CategoryInfo> categorylist = new List<CategoryInfo>();
        public List<TagsInfo> tagslist = new List<TagsInfo>();
        public List<string> formats = new List<string>();
        public List<PriceInfo> pricelist = new List<PriceInfo>();
        public int id = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            id = JobRequest.GetRequestInt("id");
            categorylist = CategoryDAL.FindAll(B.MyAdmin.ID);
            categorys = SerializeHelper.ToJson(categorylist);
            int adminid = B.MyAdmin.ID;
            tagslist = TagsDAL.FindAll(adminid);
            if (id != 0)
            {
                info = ProductDAL.FindOneByID(id);
                pricelist = PriceDAL.FindListByProductID(id);
                if (!string.IsNullOrEmpty(info.Format1)) { formats.Add(info.Format1); }
                if (!string.IsNullOrEmpty(info.Format2)) { formats.Add(info.Format2); }
                if (!string.IsNullOrEmpty(info.Format3)) { formats.Add(info.Format3); }
                if (!string.IsNullOrEmpty(info.Format4)) { formats.Add(info.Format4); }
                if (!string.IsNullOrEmpty(info.Format5)) { formats.Add(info.Format5); }
            }
            else
            {
                info.PriceType = 1;
                info.Sort = CommonDAL.MaxSort("product");
            }
        }
    }
}